﻿using IntoStationSystem.Entity;
using SQLite.CodeFirst;
using System.Data.Entity;

namespace IntoStationSystem.Db
{
    public class ConfigDbContext : DbContext
    {
        public ConfigDbContext() : base("ConfigDbContext") { }
        /// <summary>
        /// 扫码配置表
        /// </summary>
        public virtual DbSet<ScanCode> ScanCodes { get; set; }
        /// <summary>
        /// 产品配置表
        /// </summary>
        public virtual DbSet<ProductModel> ProductModels { get; set; }
        /// <summary>
        /// 流程、报警、警告信息提示
        /// </summary>
        public virtual DbSet<Msg> Msgs { get; set; }
        /// <summary>
        /// 零件码配置
        /// </summary>
        public virtual DbSet<ResetScanCode> ResetScanCodes { get; set; }
        /// <summary>
        /// 远程数据库未保存时，保存至本地
        /// </summary>
        public virtual DbSet<ProduceData> LogProduct { get; set; }
        /// <summary>
        /// 系统设置
        /// </summary>
        public virtual DbSet<SystemSetting> SystemSettings { get; set; }
        /// <summary>
        /// IO配置
        /// </summary>
        public virtual DbSet<IO> IO { get; set; }


        /// <summary>
        /// 产品型号索引
        /// </summary>
        public virtual DbSet<ModelIndex> ModelIndexs { get; set; }

        /// <summary>
        /// 气缸配置
        /// </summary>
        public virtual DbSet<Cylinder> Cylinders { get; set; }



        /// <summary>
        /// 扫码内容保存表
        /// </summary>
        public virtual DbSet<PartCodeModel> PartCodesQuery { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            var sqliteInit = new SqliteCreateDatabaseIfNotExists<ConfigDbContext>(modelBuilder);
            Database.SetInitializer(sqliteInit);
        }
    }
}
